package com.cart.protocol.analyze;
import com.cart.protocol.ProtocolDefine;

/*
    ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ 
       Author   :  lixiaodaoaaa
       Date     :  2020-01-17
       Time     :  14:03
    ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
 */
public class UltravioletRespAnalyze extends RespAnalyze {

    public UltravioletRespAnalyze(String rawDeviceInfo) {
        super(rawDeviceInfo);
    }

    @Override
    protected RespAnalyze analyze() {
        //200901cc00
        String actionResp = rawDeviceInfo.substring(0, 2);
        String operateCommand = rawDeviceInfo.substring(6, 8);

        StringBuilder responActionBuilder = new StringBuilder();

        switch (operateCommand.toUpperCase()) {
            case ProtocolDefine.OperateCommand.CLOSE:
                responActionBuilder.append("关闭");
                break;
            case ProtocolDefine.OperateCommand.OPEN:
                responActionBuilder.append("打开");
                break;
        }
        switch (actionResp.toUpperCase()) {
            case ProtocolDefine.CommandWordRes.ACTION_SUCCESS:
                responActionBuilder.append("紫外线成功！");
                break;
            case ProtocolDefine.CommandWordRes.ACTION_FAIL:
                responActionBuilder.append("开启紫外线失败！");
                break;
            default:
                break;
        }
        report = responActionBuilder.toString();
        responActionBuilder.delete(0, responActionBuilder.toString().length());
        return this;
    }
}
